package com.iphanta.community.tags.web.admin;

import com.iphanta.community.common.entity.DataResult;
import com.iphanta.community.common.utils.ResultUtils;
import com.iphanta.community.tags.service.TagsService;
import com.iphanta.community.tags.traffic.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 后台管理 - 标签
 *
 * @author 墨声 E-mail: zehong.hongframe.huang@gmail.com
 * create time: 4/25/22 11:55 AM
 */
@RestController
@RequestMapping("community/admin/tagCodes/")
public class AdminTagsController {

    @Autowired
    private TagsService tagsService;

    /**
     * 新增标签
     *
     * @param request
     * @return
     */
    @PostMapping("add")
    public DataResult<AddTagItemResponse> add(@RequestBody @Validated AddTagItemRequest request) {
        return ResultUtils.SUCCESS.result(tagsService.add(request));
    }

    /**
     * 修改标签
     *
     * @param request
     * @return
     */
    @PostMapping("modify")
    public DataResult<ModifyTagItemResponse> modify(@RequestBody ModifyTagItemRequest request) {
        return ResultUtils.SUCCESS.result(tagsService.modify(request));
    }

    /**
     * 查询一个标签
     *
     * @param request
     * @return
     */
    @PostMapping("queryOne")
    public DataResult<QueryOneTagItemResponse> queryOne(@RequestBody QueryOneTagItemRequest request) {
        return ResultUtils.SUCCESS.result(tagsService.queryOne(request));
    }

    /**
     * 查询标签列表
     *
     * @param request
     * @return
     */
    @PostMapping("query")
    public DataResult<QueryTagItemResponse> query(@RequestBody QueryTagItemRequest request) {
        return ResultUtils.SUCCESS.result(tagsService.query(request));
    }

    /**
     * 查询所有标签
     *
     * @return
     */
    @PostMapping("queryAll")
    public DataResult<AllTagItemResponse> queryAll() {
        return ResultUtils.SUCCESS.result(tagsService.queryAll());
    }

    /**
     * 标签维度
     *
     * @return
     */
    @PostMapping("tagDimension")
    public DataResult<TagDimensionResponse> tagDimension() {
        return ResultUtils.SUCCESS.result(tagsService.tagDimension());
    }

}
